home *** CD-ROM | disk | FTP | other *** search
- /* ==========================================================================
- **
- ** Interactor.c
- **
- ** ©1991 WILLISoft
- **
- ** ==========================================================================
- */
-
- #include "parms.h" /* added for proper prototyping -- EDB */
- #include "GraphicObject.h"
- #include "GraphicObjectClass.h"
-
- #include "Interactor.h"
- #include "InteractorClass.h"
- #include "pcgWindow.h"
-
- pcgWindow *Interactor_InteractorWindow( Interactor *self )
- {
- return self->IaWindow;
- }
-
-
- void Interactor_SetInteractorWindow( Interactor *self, pcgWindow *window )
- {
- self->IaWindow = window;
- }
-
-
- tPoint Interactor_Location( Interactor *self )
- {
- return self->Location;
- }
-
- tPoint Interactor_Size( Interactor *self )
- {
- return self->Size;
- }
-
- tPoint Interactor_SetLocation( Interactor *self,
- PIXELS LeftEdge,
- PIXELS TopEdge )
- {
- self->Location.x = LeftEdge;
- self->Location.y = TopEdge;
-
- return self->Location;
- }
-
- tPoint Interactor_SetSize( Interactor *self,
- PIXELS Width,
- PIXELS Height )
- {
- self->Size = AskSize( (GraphicObject *)self, Width, Height );
- return self->Size;
- }
-
- pcgWindow *InteractorWindow( Interactor *self )
- {
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->InteractorWindow )
- return (*class->InteractorWindow)( self );
- }
- else
- return NULL;
- }
-
-
- void SetInteractorWindow( Interactor *self, pcgWindow *window )
- {
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->SetInteractorWindow )
- (*class->SetInteractorWindow)( self, window );
- }
- }
-
-
-
- Gadget *FirstGadget( Interactor *self )
- {
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->FirstGadget )
- return (*class->FirstGadget)( self );
- }
- else
- return NULL;
- }
-
-
- USHORT nGadgets( Interactor *self )
- {
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->nGadgets )
- return (*class->nGadgets)( self );
- }
- else
- return 0;
- }
-
-
- ULONG IDCMPFlags( Interactor *self )
- {
- ULONG flags = 0;
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->IDCMPFlags )
- flags = (*class->IDCMPFlags)( self );
- }
- return flags;
- }
-
-
-
- USHORT ClaimEvent( Interactor *self,
- IntuiMessage *event )
- {
- USHORT claimed = 0;
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->ClaimEvent )
- claimed = (*class->ClaimEvent)( self, event );
- }
- return claimed;
- }
-
-
- USHORT Respond( Interactor *self,
- IntuiMessage *event )
- {
- USHORT response = 0;
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->Respond )
- response = (*class->Respond)( self, event );
- }
- return response;
-
- }
-
- void Refresh( Interactor *self )
- {
- struct InteractorClass *class;
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->Refresh )
- (*class->Refresh)( self );
- }
-
- }
-
-
- BOOL EnableIactor( Interactor *self,
- BOOL enable )
- {
- BOOL enabled = 0;
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->EnableIactor )
- enabled = (*class->EnableIactor)( self, enable );
- }
- return enabled;
-
- }
-
-
- BOOL isEnabled( Interactor *self )
- {
- BOOL enabled = 0;
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->isEnabled )
- enabled = (*class->isEnabled)( self );
- }
- return enabled;
-
- }
-
-
-
- BOOL Activate( Interactor *self,
- BOOL activate )
- {
- BOOL active = 0;
- struct InteractorClass *class;
-
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->Activate )
- active = (*class->Activate)( self, activate );
- }
- return active;
-
- }
-
-
- BOOL isActive( Interactor *self )
- {
- BOOL active = 0;
- struct InteractorClass *class;
-
- if( class = (struct InteractorClass *)self->isa )
- {
- if( class->isActive )
- active = (*class->isActive)( self );
- }
- return active;
- }
-
-
- void Interactor_Refresh( Interactor *self )
- {
- pcgWindow *window;
-
- /* If the subclasses have not redefined this, then simply
- * render it.
- */
-
- if( window = InteractorWindow( self ) )
- {
- Render( (GraphicObject *)self, window->Window->RPort );
- }
- }
-
- void Interactor_CleanUp( Interactor *self )
- {
- pcgWindow *w = InteractorWindow( self );
-
- if( w )
- {
- RemoveWindowPObject( w, (GraphicObject *)self );
- }
- }
-
-
- BOOL Interactor_elaborated = FALSE;
-
- struct InteractorClass Interactor_Class;
-
- void InteractorClass_Init( struct InteractorClass *class )
- {
- GraphicObjectClass_Init( (struct GraphicObjectClass *) class );
- class->isa = GraphicObjectClass();
- class->ClassName = "Interactor";
- class->CleanUp = (void(*)(PObject *))Interactor_CleanUp;
-
- class->Location = (Point(*)(GraphicObject *))Interactor_Location;
- class->SetLocation = (Point(*)(GraphicObject *, PIXELS, PIXELS))Interactor_SetLocation;
- class->Size = (Point(*)(GraphicObject *))Interactor_Size;
- /* class->AskSize = NULL;*/
- class->SetSize = (Point(*)(GraphicObject *, PIXELS, PIXELS))Interactor_SetSize;
- /*class->SizeFlags = GraphicObject_SizeFlagsAll;*/
- /* class->Render = NULL;*/
- class->InteractorWindow = Interactor_InteractorWindow;
- class->SetInteractorWindow = Interactor_SetInteractorWindow;
- /* class->FirstGadget = NULL;*/
- /* class->nGadgets = NULL;*/
- /* class->IDCMPFlags = NULL;*/
- /* class->ClaimEvent = NULL;*/
- /* class->Respond = NULL;*/
- class->Refresh = Interactor_Refresh;
- /* class->EnableIactor = NULL;*/
- /* class->isEnabled = NULL;*/
- /* class->Activate = NULL;*/
- /* class->isActive = NULL;*/
- }
-
-
- struct InteractorClass *InteractorClass( void )
- {
- if( ! Interactor_elaborated )
- {
- InteractorClass_Init( &Interactor_Class );
- Interactor_elaborated = TRUE;
- }
-
- return &Interactor_Class;
- }
-
-
- void Interactor_Init( Interactor *self )
- {
- GraphicObject_Init( (GraphicObject *)self );
- self->isa = InteractorClass();
- self->IaWindow = NULL;
- self->Location.x = 0;
- self->Location.y = 0;
- self->Size.x = 0;
- self->Size.y = 0;
- }
-
-
- BOOL ActivateNext( Interactor *self )
- {
- Interactor *iactor;
- pcgWindow *pwindow;
-
- for( iactor = self->Next; iactor != NULL; iactor = iactor->Next )
- if( Activate( iactor, TRUE ) ) return TRUE;
-
- /* couldn't find an activatable interactor. Try from start of chain. */
- pwindow = InteractorWindow( self );
- if( pwindow )
- {
- for( iactor = pwindow->FirstInteractor; iactor != self; iactor = iactor->Next )
- if( Activate( iactor, TRUE ) ) return TRUE;
-
-
- }
-
- return Activate( self, TRUE ); /* reactivate the same interactor. */
- }
-
-